<template>
  <div style="background-color:white">
    <el-popover
      placement="bottom"
      popper-class="pop"
      trigger="click"
      :width="360"
    >
      <template #reference>
        <el-button  style="background-color:ghostwhite">
          <span class="user_count">{{UserName}}&nbsp;&nbsp;</span>
          <img class="user_icon" src="@/assets/image/root/down.png" alt="" />
        </el-button>
      </template>
      <div class="span_item_user">
        <div class="spa">
          <el-avatar/>
          <span class="user_text">
            <p>用户级别：</p>
            <span>普通用户</span>
          </span>
          <el-button class="rest" type="primary" @click="dialogVisible = true"
            >查询订单</el-button>
        </div>
        <div class="span1" @click="onExit">
          <i class="iconfont icon-tuichu back"></i><span>退出登录</span>
        </div>
      </div>
    </el-popover>
    <el-dialog
      :draggable="true"
      v-model="dialogVisible"
      :show-close="false"
      title="重置密码"
      :style="{ width: '400px' }"
    >
      <el-form
        :model="form"
        label-position="left"
        :rules="rules"
        ref="ruleFormRef"
      >
        <el-form-item label="设置新密码" prop="code">
          <el-input autocomplete="off" />
        </el-form-item>
        <el-form-item label="确认新密码" prop="codeCopy">
          <el-input autocomplete="off" />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary">
            确认
          </el-button>
          <el-button>取消</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script setup>
import { ref, onMounted, reactive } from "vue";
const dialogVisible = ref(false);

const UserId = localStorage.getItem('UserId')
const UserName = localStorage.getItem('User')

const { text, userJob } = defineProps({
  text: {
    type: String,
    default: "账户名",
    required: false,
  },
  userJob: {
    type: String,
    default: "超级管理员",
    required: false,
  },
});
const form = reactive({
  code: "",
  codeCopy: "",
});

function onExit() {
  localStorage.removeItem('Authorization');
  localStorage.removeItem('UserId');
  localStorage.removeItem('UserName');
  window.location.href = "/";
  return false;
}
const ruleFormRef = ref();
onMounted(() => {});
</script>
<style lang="scss">
.user_find_data {
  height: 100%;
  .user_item {
    height: 100%;
    display: flex;
    align-items: center;
    background-color: #ffffff;
    border: 1px #ffffff solid;
    .user_img {
      margin-left: 22px;
    }
    .user_count {
      line-height: 28px;
      margin-left: 5px;
      color: #000000;
    }
    .user_icon {
      margin-left: 10px;
      margin-right: 15px;
    }
  }

  // .spanItem{
  //   width: 340px;
  //   height: 148px;
  //   border-radius: 20px;
  //     .spa{
  //       display: flex;
  //       align-items: center;
  //       height: 100px;
  //       padding: 0 20px;
  //       justify-content: space-between;
  //       background: #F5F8FF;
  //       .el-avatar{
  //        width: 60px;
  //        height: 60px;

  //       //  margin-top:20px;
  //        margin-right:20px ;
  //       }
  //       >span{
  //         display: flex;
  //         flex-direction: column;
  //         justify-content: center;
  //         height: 100%;

  //         >span{
  //           font-size: 16px;
  //           color: var(--el-bg-color-header-title);
  //           margin-top: 14px;
  //         }
  //         >p{
  //           font-size: 14px;
  //           color: var(--el-bg-color-header-text);
  //         }
  //       }
  //       .rest{
  //         width: 90px;
  //         height: 32px;
  //         border-radius: 5px;
  //       }

  //     }
  //     .span1{
  //       text-align: center;
  //       line-height:54px;
  //       cursor:pointer;
  //     }
  //   }
}
.pop {
  // width: 360px;

  // border: 1px solid #DEE2EC;
  // box-shadow: 0px 2px 15px 1px rgba(194,194,194,0.34);
  // border-radius: 20px;
  // padding: 0;
  width: 360px;
  height: 168px;
  border: 1px solid #dee2ec;
  box-shadow: 0px 2px 15px 1px rgba(194, 194, 194, 0.34);
  border-radius: 20px !important;
  padding: 0 !important;
}
.span_item_user {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  .spa {
    display: flex;
    align-items: center;
    height: 100px;
    padding: 0 20px;
    background: #f5f8ff;
    border-radius: 20px 20px 0 0;
    padding-left: 30px;
    .el-avatar {
      width: 60px;
      height: 60px;
    }
    .user_text {
      display: flex;
      flex-direction: column;
      justify-content: center;
      height: 100%;
      margin-left: 16px;
      margin-right: 52px;
      > span {
        font-size: 16px;
        color: var(--el-bg-color-header-title);
        margin-top: 14px;
      }
      > p {
        font-size: 14px;
        color: var(--el-bg-color-header-text);
      }
    }
    .rest {
      width: 90px;
      height: 32px;
      border-radius: 5px;
    }
  }
  .span1 {
    text-align: center;
    line-height: 54px;
    cursor: pointer;
    > span {
      font-size: 14px;
      margin-left: 6px;
    }
  }
}
</style>
